<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="csrf-token" content="{{ csrf_token() }}">
	<title>商城</title>
	<link rel="stylesheet" href="{{ asset('home/css/bootstrap.min.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/font-awesome.min.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/atstyle.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/bmap.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/bootstrap-datetimepicker.min.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/owl.carousel.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/owl.transitions.css') }}">
	<link rel="stylesheet" href="{{ asset('home/css/magnific-popup.css') }}">


    <link rel="stylesheet" href="{{ asset('css/font-awesome.min.css') }}">

	<script src="{{ asset('home/js/jquery-2.1.1.min.js') }}"></script>
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.0/bootbox.min.js"></script>
</head>
<body class="common-home">
	<header> <!--顶部菜单-->
		@component('home.components.topnav') @endcomponent
		<div class="container">
			@component('home.components.cart-logo') @endcomponent
			@component('home.components.main-nav')@endcomponent
		</div>
	</header> <!--/顶部结束/-->

	<div class="container">
		<div class="row">
			@yield('content')
		</div>
	</div>

	@include('home.includes.footer')
	<script src="{{ asset('home/js/bootstrap.min.js') }}"></script>
	<script src="{{ asset('home/js/owl.carousel.min.js') }}"></script>
	<script src="{{ asset('home/js/common.js') }}"></script>
	<script src="{{ asset('home/js/custom.js') }}"></script>
	<script src="{{ asset('home/js/jquery.magnific-popup.min.js') }}"></script>
	<!-- <script src="{{ asset('home/js/bootstrap-datetimepicker.min.js') }}"></script> -->
	<script src="{{ asset('home/js/jquery.custom.min.js') }}"></script>
	<script src="{{ asset('home/js/moment.js') }}"></script>
	<script src="{{ asset('home/js/jquery.elevatezoom.min.js') }}"></script>
	<script type="text/javascript" src="{{ asset('js/bootbox.min.js') }}"></script>

	<script>
        $(function() {
        	$.ajaxSetup({
			    headers: {
			        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
			    }
			});

        	$("a[data-type=delete]").on('click', function() {
        		const url = $(this).data('url');
        		bootbox.confirm("确认删除！", function(result){ 
				    if(result) {
				    	$.ajax({
				    		url:url,
				    		type:'delete',
				    		success: res => {
				    			location.reload();
				    		}
				    	})
				    }
				});
        	});

        	$(".wishlist_button").on('click', function() {
        		const goods_id = $(this).data('goods_id');
        		$.ajax({
        			url:"{{ route('collections.store') }}",
        			type:'post',
        			data:{goods_id:goods_id},
        			success: res => {
        				var dialog1 = bootbox.dialog({
						    message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i>收藏成功</p>',
						    closeButton: false
						});
						setTimeout(function() {
							dialog1.modal('hide');
						}, 1000)
        			},
        			error: res => {
        				//console.log(res.status)
        				if(res.status == 401)
        				{
        					location.href="{{ route('user.login') }}"
        				}
        			}
        		})
        	})

            $(".compare").on('click', function(e) {
                //alert('bijiao');
                const goods_id = $(this).data('goods_id');
        
                $.ajax({
                    url:"{{ route('compare.store') }}",
                    type:'post',
                    data: {
                        goods_id:goods_id
                    },
                    success:res => {
                        console.log(res)
                    }
                })
            })

        	$(".cart_button, #addToCart, .fa-shopping-cart").on('click', function(e) {
        		const goods_id = $(this).data('goods_id');
        		$.ajax({
        			url:"{{route('carts.store')}}",
        			type:'post',
        			data:{
        				goods_id:goods_id,
        				quantity:1,
        			},
        			success:res => {
        				console.log(res);
        				var dialog = bootbox.dialog({
						    message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i>加入购物车成功</p>',
						    closeButton: false
						});
						setTimeout(function() {
							dialog.modal('hide');
						}, 1000)
						
        			}
        		})
        	})

            var fp_carousel_0 = $('#featured_products_carousel_0');
            fp_carousel_0.owlCarousel({
            items: 4,
            itemsDesktop: [1199, 3],
            itemsDesktopSmall: [900, 3],
            itemsTablet: [767, 2],
            autoWidth: true,
            autoPlay: false,
            pagination: false,
            navigation: true,
            navigationText: [
                "<i class='fa fa-caret-left fa-5x'></i>",
                "<i class='fa fa-caret-right fa-5x'></i>"
            ],
            stopOnHover: true
            });

            $("#logout").on('click', function(e) {
            	$.ajax({
            		url:"{{route('user.logout')}}",
            		type:'post',
            		success: res => {
            			location.reload()
            		}
            	});
            })
        })
    </script>

    @yield('script')
</body>
</html>